package com.coda.controller;

import com.coda.common.PageResult;
import com.coda.common.Result;
import com.coda.dto.PageDto;
import com.coda.entity.OutStore;
import com.coda.entity.Store;
import com.coda.service.OutStoreService;
import com.coda.service.StoreService;
import com.coda.service.impl.StoreServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/warehouse/outstore")
@Api(tags = "出库相关接口")
public class OutStoreController {

    @Autowired
    private OutStoreService outStoreService;
    @Autowired
    private StoreService storeService;

    /**
     * 添加出库单
     */
    @PostMapping("/outstore-add")
    @ApiOperation("添加出库单")
    public Result addOutStore(@RequestBody OutStore outStore){
        outStoreService.addOutStore(outStore);
        return Result.ok("添加成功");
    }

    /**
     * 分页查询
     * @param pageDto
     * @param outStore
     * @return
     */
    @GetMapping("/outstore-page-list")
    @ApiOperation("分页查询")
    public Result getPage(PageDto pageDto,OutStore outStore){
        PageResult pageResult = outStoreService.getPage(pageDto,outStore);
        return Result.ok(pageResult);
    }

    /**
     * 查看仓库列表
     * @return
     */
    @GetMapping("/store-list")
    @ApiOperation("仓库列表")
    public Result getStoreList(){
        List<Store> storeList = storeService.getStoreList();
        return Result.ok(storeList);
    }

    /**
     * 确定出库
     */
    @PutMapping("/outstore-confirm")
    @ApiOperation("确定出库")
    public Result isOutStore(@RequestBody OutStore outStore){
        outStoreService.isOutStore(outStore);
        return Result.ok("出库成功");
        
    }
}
